package org.example.domain.activity_manage.service.Impl;

import lombok.extern.slf4j.Slf4j;
import org.example.domain.activity_manage.model.entity.ActivityEntity;
import org.example.domain.activity_manage.repository.IActivityRepo;
import org.example.domain.activity_manage.service.IActivityService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author lxc18
 * @date 2025/3/17 20:28
 * @description IActivityServiceImpl
 */
@Slf4j
@Service
public class IActivityServiceImpl implements IActivityService {
    private static Logger logger = LoggerFactory.getLogger(IActivityServiceImpl.class);
    @Resource
    private IActivityRepo activityRepo;
    @Override
    public boolean createActivity(ActivityEntity activityEntity) {
        try {
            activityRepo.createActivity(activityEntity);
            return true;
        } catch (Exception e) {
            logger.error("创建活动失败:{}",e.getMessage());
            return false;
        }

    }

    @Override
    public boolean updateActivity(ActivityEntity activityEntity) {
        try {
            activityRepo.updateActivity(activityEntity);
            return true;
        }
        catch (Exception e){
            logger.error("更新活动失败:{}",e.getMessage());
            return false;
        }
    }

    @Override
    public boolean deleteActivity(Long activityId) {
        try {
            activityRepo.deleteActivity(activityId);
            return true;
        }
        catch (Exception e){
            logger.error("删除活动失败:{}",e.getMessage());
            return false;
        }
    }

    @Override
    public List<ActivityEntity> queryActivityByName(String activityName) {
        return activityRepo.queryActivityByName(activityName);
    }

    @Override
    public ActivityEntity queryActivityById(Long activityId) {
        return activityRepo.queryActivityById(activityId);
    }

    @Override
    public List<ActivityEntity> queryActivityByPage(int pageNum, int pageSize) {
        return activityRepo.queryActivityByPage(pageNum, pageSize);
    }
}
